package com.sky.mapper;

import com.sky.result.PriceAndNumber;
import com.sky.result.Top10Result;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface ReportMapper {

    /**
     * 营业额
     * */
    List<PriceAndNumber> getAmount(LocalDate begin, LocalDate end, Integer status);

    /**
     * 获取用户总数
     * */
    @Select("select count(id) from user where create_time < #{end}")
    Integer getSumUser(LocalDate end);

    /**
     * 获取新用户数
     * */
    @Select("select count(id) from user where create_time BETWEEN #{begin} AND #{end}")
    Integer getNewUser(LocalDate begin, LocalDate end);

    /**
     * 获取订单总数
     * */
    Integer getOrderSum(Integer status,LocalDate begin,LocalDate end);

    /**
     * 有效订单总数
     * */
    @Select("select cocunt(id) from orders where status=#{status} and order_time < #{end}")
    Integer getValidOrderSum(Integer status, LocalDate end);


    /**
     * 查询销量排名top10
     * */
    List<Top10Result> top(LocalDate begin, LocalDate end);
}
